Skip to content

feat(events): hover during captureGesture + expose hitTest (A20)#85

Merged
re-marked merged 2 commits into
mainfrom
feat/expose-hittest-and-hover-during-capture
May 9, 2026
Merged

feat(events): hover during captureGesture + expose hitTest (A20)#85
re-marked merged 2 commits into
mainfrom
feat/expose-hittest-and-hover-during-capture

Conversation

@re-marked

Copy link
Copy Markdown
Owner

Closes #73 (A20).

What

Two surgical changes:

  1. App.tsx: also dispatch hover (via existing `onHoverAt` → `dispatchHover`) during a captured drag's motion. `onMouseEnter` / `onMouseLeave` are side-effect-only and don't compete with the gesture's `onMove` for the input. Drop targets and other passive observers can now react to cursor position mid-drag without the gesture initiator coordinating anything.

  2. index.ts: re-export `hitTest` so consumers can resolve "what element is at this cursor right now?" from inside a captured `onMove` handler — typical use is custom drop-target detection, drag-ghost positioning, hover-during-drag UX.

Tests

  • New `describe('hitTest')` and `describe('dispatchHover')` blocks in `hit-test.test.ts` (6 new tests covering deepest-element-wins, off-root null, sibling-walk, enter/leave diff, idempotent same-cell)
  • 714 tests passing (was 708; +6)

Docs

  • `docs/reference/events.md`: `captureGesture` docstring now notes that hover events keep firing during capture; new bullet for `captureGestureTentatively` (was implicit, now documented for completeness)
  • `docs/concepts/mouse.md`: new "Tentative capture" + "Programmatic hit-testing" sections at the bottom

Net effect

Custom drag interactions are now fully composable. The drop-target-during-drag pattern that termos hand-rolled (FileList registers a RowHitTest closure; DragContext.move calls it on every cell-cross) becomes obsolete — consumers can either let `onMouseEnter` fire on each row passively, or call `hitTest` from inside their gesture's `onMove`.

App.tsx now also dispatches hover during captured drag motion so drop
targets can react to cursor position without reinventing hit-testing.
Re-export hitTest from the package index for consumers using captured
gestures with custom drop-detection logic.

Co-Authored-By: Mark <psyhik17@gmail.com>
Co-Authored-By: Claude <noreply@anthropic.com>
@re-marked re-marked added the source:shakedown Imported from the local Yokai shakedown issue list label May 9, 2026

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 115e87c961

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +838 to +841
if (col !== app.lastHoverCol || row !== app.lastHoverRow) {
app.lastHoverCol = col
app.lastHoverRow = row
app.props.onHoverAt(col, row)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Avoid hit-testing drag hover against the drag ghost

When the captured gesture is a normal <Draggable>, the dragged box stays under the cursor and is rendered as an absolute node with the drag-time z boost, while onHoverAt ultimately calls dispatchHover/hitTest, which returns the topmost painted node. In that common drag-over-sibling case this newly added hover dispatch keeps hitting the draggable itself instead of the drop zone or passive observer underneath, so the documented onMouseEnter-during-drag behavior does not fire for the target the cursor is visually being dragged over unless the drag source does not cover the cursor.

Useful? React with 👍 / 👎.

@re-marked
re-marked merged commit 321f753 into main May 9, 2026
1 check passed
@re-marked
re-marked deleted the feat/expose-hittest-and-hover-during-capture branch May 9, 2026 14:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

source:shakedown Imported from the local Yokai shakedown issue list

Projects

None yet

Development

Successfully merging this pull request may close these issues.

A20: Hover events suppressed during captureGesture

1 participant